package com.example.park.config;

import com.example.park.dao.ParkShareDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class StateScheduledConfig {

    @Autowired
    private ParkShareDao parkShareDao;

    public StateScheduledConfig() {
        parkShareDao = SpringUtils.getBean(ParkShareDao.class);
    }

    @Scheduled(cron = "0 0 * * * ?")
    // cron内表达式意思（0秒0分每时每日每月每年），设定定时器用于修改已发布的闲时记录的状态
    @Async
    // 更新闲时数据是否过期
    public void updateState() {
        parkShareDao.updateState();
    }

}
